package com.example.webdriveddd.controller;

import com.example.webdriveddd.application.Application;
import com.example.webdriveddd.application.IllegalArgException;
import com.example.webdriveddd.dto.UserDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IdentityController {
    @Autowired
    private Application application;

    @PostMapping("/register")
    public UserDTO register(@RequestParam("username")String username,@RequestParam("password")String password) throws IllegalArgException {
        UserDTO userDTO=new UserDTO();
        userDTO.setUsername(username);
        userDTO.setPassword(password);
        return application.register(userDTO.getUsername(),userDTO.getPassword());
    }
}
